package com.theme.passport.service.theme.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.utils.Query;
import com.theme.passport.dao.theme.AppIconDao;
import com.theme.passport.dao.theme.SearchHistoryDao;
import com.theme.passport.entity.theme.AppIconEntity;
import com.theme.passport.service.theme.AppIconService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("appIconService")
public class AppIconServiceImpl extends ServiceImpl<AppIconDao, AppIconEntity> implements AppIconService {

    @Autowired
    private AppIconDao appIconDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String keyword = (String) params.get("key");
        String status = (String) params.get("status");
        IPage<AppIconEntity> page = this.page(
                new Query<AppIconEntity>().getPage(params),
                new QueryWrapper<AppIconEntity>()
                        .eq(StringUtils.isNotBlank(status), "status", status)
                        .like(StringUtils.isNotBlank(keyword), "name", keyword)
                        .orderByDesc("origin")
        );
        return new PageUtils(page);
    }

    @Override
    public AppIconEntity getByName(String appName) {

        return appIconDao.getByName(appName);
    }

}